1. Field of the Invention
Embodiments of the present invention generally relate to computer graphics, and more particularly to anisotropic filtering of texture data.
2. Description of the Related Art
Conventional graphics processors are exemplified by systems and methods developed to read and filter texture map samples. To simplify the texture map filtering performed within a graphics processor, a texture is prefiltered and various resolutions forming an image pyramid or “mipmap stack” are stored. FIG. 1A is a conceptual diagram of prior art showing the levels of a mipmapped texture including the finest level, level 101, and successively lower resolution levels, 102, 103, and 104.
The region in texture space corresponding to a pixel is called the pixel's “footprint”. A pixel can be approximated with a circle in screen space. For texture mapping of two-dimensional textures, the corresponding footprint in texture space can be approximated by an ellipse. In classic use of mipmaps, a mipmap level is chosen so that the footprint when scaled to that level is about 1 texel (texture pixel) in diameter. Then a bilinear filter is used to interpolate between the values of four texels forming a 2×2 square around the footprint center, to produce a bilinear texture sample. This is called isotropic filtering, because it filters equally in the two texture space dimensions, u and v. Although the filter yielding excellent image quality, the ideal filter, has an approximately elliptical shape, isotropic filtering approximates the ellipse with a circle that is too large, to simplify the texture sampling and filtering computations. Therefore, portions of the texture that are outside of the footprint are sampled, resulting in visual artifacts, such as blurring, caused by oversampling.
In FIG. 1A, a footprint 115 is a pixel footprint in texture space, with a position 135 being the footprint center. FIG. 1B illustrates a prior art application of texture level 101 applied to pixels of a surface 140 that is receding in image space. When viewed in image space, footprint 115 (an ellipse) appears as circle 116. All ellipses have a largest diameter, called the major axis, and a smallest diameter, called the minor axis. Isotropic filtering yields high quality images for pixels whose footprints have major and minor texture axes that are similar in length. But texture stretching, oblique viewing, and perspective can cause footprints to be very elongated, such as footprint 115. When isotropic filtering is used in such situations, a circle is not a good approximation of an ellipse. If the circle is too small (diameter close to the minor axis), the filter is too sharp, too few texels are averaged, and aliasing results. If the circle is too large (diameter close to the major axis), the filter is too broad, too many texels are averaged, and blurring results. Anisotropic texture filtering addresses this problem by using a filter that more closely matches the elliptical shape of the ideal filter.
FIG. 1C illustrates footprint 115 including a minor axis 125 that is significantly shorter than a major axis 130. Texture samples along major axis 130, the axis of anisotropy, are read from one or more mipmap levels and are blended to produce a pixel color. The level from which the samples are read is determined using a level of detail (LOD) value which is nominally the log base 2 of the length of minor axis 125. The number of texture samples read from the texture map is determined based on the ratio of the major axis to the minor axis, the anisotropic ratio, with more texture samples needed as the ratio increases, i.e. as the ellipse becomes more elongated.
FIG. 1D illustrates four bilinear texture samples, bilinear samples 140, bilinear sample 142, and bilinear sample 144 that are positioned along major axis 130 to approximate an elliptical footprint, such as footprint 115. Each bilinear sample corresponds to an isotropically filtered texture sample for an LOD of a texture map that is computed using conventional bilinear isotropic filtering. Bilinear samples from one or more LODs of a texture map are filtered to produce an anisotropically filtered texture sample corresponding to pixel 116. When the anisotropic ratio of the footprint is greater than two and not divisible by two, additional bilinear samples are positioned at opposing ends of the major axis. For example, bilinear samples 142 and 144 are positioned at opposing ends of footprint 115 (having an anisotropic ratio that is greater than two and less than four), adjacent to bilinear samples 140. The additional bilinear samples oftentimes extend beyond the major axis, e.g., bilinear samples 142 and 144 extend beyond major axis 130, and therefore include texture samples which lie outside of the elliptical footprint, possibly resulting in visual artifacts such as blurring. The number of bilinear samples and spacing of the bilinear samples should be determined such that all of the bilinear samples lie within the elliptical footprint.
Accordingly, there is a need to position bilinear texture samples within the elliptical footprint when performing anisotropic texture mapping for anisotropic ratios that are not divisible by two.